package cn.zindesign.base.impl;

import java.util.List;
import java.util.Map;

import org.apache.ibatis.session.RowBounds;
import org.mybatis.spring.support.SqlSessionDaoSupport;

import cn.zindesign.base.BaseMapper;

/**
 * @author lihui
 * Jan 5, 2012
 * @param <T>
 * 此类是mapper类的基类，提供单表查询的基本方法，mapperid与xml中的sql id固定搭配
 */
public class BaseMapperImpl extends SqlSessionDaoSupport implements BaseMapper {


	public List<Object> selectByProperty(String key,Map<?, ?> map){
		return  getSqlSession().selectList(key+".selectByProperty", map);
	}

	public int countByProperty(String key, Map<?, ?> map) {
		return (Integer) getSqlSession().selectOne(key+".countByProperty", map);
	}

	public int deleteById(String key, Integer id) {
		return getSqlSession().delete(key+".deleteById", id);
	}

	public int insert(String key, Object record) {
		return getSqlSession().insert(key+".insert", record);
	}

	public Object selectById(String key, Integer id) {
		return (Object) getSqlSession().selectOne(key+".selectById", id);
	}

	public int updateById(String key, Object record) {
		return getSqlSession().update(key+".updateById", record);
	}

	public List<Object> selectByProperty(String key, Map<?, ?> map, int offset, int limit) {
		return getSqlSession().selectList(key+".selectByProperty", map, new RowBounds(offset,limit));
	}
}
